#pragma once
#include <map>
#include "TinyDBLayer/TinyDBInterface.h"
#include "TinyDBLayer/TinyDBMysqlInterface.h"
#include <vector>
#include <map>

template<class T>
class CTinyDBMapper
{
public:
	CTinyDBMapper(){};
	virtual ~CTinyDBMapper(void){};
	//virtual bool loadData(int type,CTinyDBInterface* m_DBIF)=0;
	virtual std::vector<T*>* GetAll()=0;
	sql::ResultSet * executeSql(std::string sqlStr)
	{
		try{
			return (sql::ResultSet*)m_DBIF->executeSQL(sqlStr);
		}
		catch (sql::SQLException &e) {
			std::string err =  e.what();
			return NULL;
		}
	}
	virtual void init(int dbtype,CTinyDBInterface* dbIF)
	{
		m_DBType = dbtype;
		m_DBIF=dbIF;
	}
	void setFilter(std::string & filterstr){m_filterStr = filterstr;};
protected:
	std::string m_filterStr;
	std::vector<std::map<std::string,std::string> > m_MapperData;
public:
	int m_DBType;
	CTinyDBInterface * m_DBIF;
	sql::ResultSet * mysql_result;
protected:
	std::string selectStr;
	//static string updateStr;
	//static string deleteStr;
};
